package com.scalar.forecast.projectSetup.actions;

import com.scalar.forecast.ForecastExtendedAction;
import com.scalar.forecast.commons.SessionKeys;
import com.scalar.forecast.projectSetup.actionCommands.MapPartNumbersActionCommandFactory;
import com.scalar.forecast.actionCommands.ActionCommand;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionMapping;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.HashMap;

/** Action Class for processing the requests came from Map Part Numbers Screen
 *
 * Created by Veeru.
 * Date: Oct 10, 2005
 * Time: 5:44:11 PM
 */


public class MapPartNumbersAction extends ForecastExtendedAction {



    public ActionForward executeRequest( ActionMapping mapping,
                                         ActionForm form,
                                         HttpServletRequest request,
                                         HttpServletResponse response ) throws Exception {

        ActionForward actionForward = mapping.findForward("mapPartNumbers");
        String action    = request.getParameter("action");
        HashMap errors = new HashMap ();
        request.setAttribute( SessionKeys.ERROR_MESSAGES, errors );
        try {
            if ( action == null ) {
                action = ACTION_SHOW;
            }
            ActionCommand actionCommand = MapPartNumbersActionCommandFactory.getActionCommand( action );
            actionForward = actionCommand.execute( mapping, form, request, response );

        } catch( Exception e){
             errors.put("Error while processing the Map Part Numbers Action", null);
        }
        return actionForward ;
    }
}
